﻿<html>
<head>
<META http-equiv="refresh" content="60" />
<style>
th{
	font-size:12px;
}
td{
	font-size:12px;
}
</style>
</head>
<body>
<form action="#">
	<select id="matchTime" name="matchTime">
    	<option value="01">01月</option>
    	<option value="02">02月</option>
    	<option value="03">03月</option>
    	<option value="04">04月</option>
    	<option value="05">05月</option>
    	<option value="06">06月</option>
    	<option value="07">07月</option>
    	<option value="08">08月</option>
    	<option value="09">09月</option>
    	<option value="10">10月</option>
    	<option value="11">11月</option>
    	<option value="12">12月</option>
    </select>
	<input type="submit" value="查询">
</form>
<?php
@$matchTime = $_GET["matchTime"];

if($matchTime == NULL){
	$matchTime = date('Y-m');
}else{
	$matchTime = date('Y').'-'.$matchTime;
}

$month = explode('-', $matchTime);
$month = $month[1];

echo '<script type="text/javascript">';
echo 'var selectObj = document.getElementById("matchTime");';
echo 'for(var i=0;i<selectObj.options.length;i++){';
echo '	if(selectObj.options[i].value=="'.$month.'"){';
echo '  	selectObj.options[i].selected=true;';
echo '      break;';
echo '	}';
echo '}';
echo '</script>';

$config = require 'conf/config.ini.php';      //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);
mysql_query("SET NAMES utf8");

$sql = "SELECT LEFT( w.userInTime, 10 ) date, COUNT( * ) count0, COUNT( DISTINCT CONCAT( w.matchId, w.userIp, w.userMac ) ) count1, COUNT( DISTINCT CONCAT( w.userIp, w.userMac ) ) count2, COUNT( DISTINCT w.userId ) count3 ";
$sql .= "FROM live_watch w ";
$sql .= "WHERE LEFT( w.userInTime, 7 ) =  '". $matchTime ."' ";
$sql .= "GROUP BY LEFT( w.userInTime, 10 ) ";
$sql .= "ORDER BY LEFT( w.userInTime, 10 ) DESC";

$watchList = mysql_query($sql, $conn);
?>
<table width="100%">
	<tr>
    	<th>日期</th>
    	<th>总次数</th>
    	<th>总人次</th>
    	<th>总访客</th>
    	<th>会员</th>
    </tr>
<?php	
while ($watch = mysql_fetch_object($watchList)) {
	echo	'<tr align="center">';
	echo	'<td><a href="get_live_watch_r.php?matchTime=' . $watch->date . '" target="rank">' . $watch->date . '</a></td>';
	echo	'<td>' . $watch->count0 . '</td>';
	echo	'<td>' . $watch->count1 . '</td>';
	echo	'<td>' . $watch->count2 . '</td>';
	echo	'<td>' . $watch->count3 . '</td>';
	echo	'</tr>';
}
?>
</table>
</body>
</html>